#include "SelectorListImpl.h"
#include "Selector.h"
#include <assert.h>

SelectorListImpl::SelectorListImpl()
{

}

SelectorListImpl::~SelectorListImpl()
{
	ClearVector();
}

int SelectorListImpl::getLength()const
{
	return m_selectors.size();
}

Selector& SelectorListImpl::item(int index)const
{
	assert(index >=0 && index < (int)m_selectors.size());
	assert(m_selectors[index]);
	return *m_selectors[index];
}

void SelectorListImpl::setSelectors(const vector<Selector*>& aSelectors)
{
	ClearVector();
	for(size_t i = 0; i < aSelectors.size(); ++i)
	{
		assert(aSelectors[i]);
		add(*aSelectors[i]);
	}
}

void SelectorListImpl::add(const Selector& aSelector)
{
	m_selectors.push_back(aSelector.Copy());
}

void SelectorListImpl::ClearVector()
{
	for(size_t i = 0; i < m_selectors.size(); ++i)
	{
		if(m_selectors[i])
			delete m_selectors[i];
	}
	m_selectors.clear();
}

